#!/bin/bash
source src/conf/config.conf
cd $tftp_dir
touch pxelinux.cfg/xen.cfg
echo " Downloading Xenserver ..."

wget -p -c  logos/xenserver.tar.gz

#wget -c  http://pxe.sytes.net/xenserver.tar.gz 

tar -zxvf xenserver.tar.gz -C xenserver/
 
mkdir tars
mv xen*.tar.gz tars/
 


cat >> pxelinux.cfg/hypervisors << EOF

DEFAULT install
PROMPT 1
TIMEOUT 50 
menu title Hypervisor Installer
menu include pxelinux.cfg/graphics.conf
MENU BACKGROUND pxelinux.cfg/background.png


MENU BEGIN hyp-submenu
 LABEL Previous
        MENU LABEL Previous Menu
        TEXT HELP
        Return to previous menu
        ENDTEXT
        MENU EXIT
 MENU TITLE Install XEN Server
MENU INCLUDE pxelinux.cfg/xen.cfg

MENU END

EOF


cat >> pxelinux.cfg/xen.cfg << EOF

LABEL Install XEN server
	KERNEL mboot.c32
	APPEND xenserver/boot/xen.gz dom0_max_vcpus=1-2 dom0_mem=max:752M com1=115200,8n1 console=com1,vga --- xenserver/boot/vmlinuz xencons=hvc console=hvc0 console=tty0 answerfile=http://pxe.sytes.net/answerfiles/xena.cfg  --- xenserver/install.img
LABEL Install XEN server no-serial
	KERNEL mboot.c32
	APPEND xenserver/boot/xen.gz dom0_max_vcpus=1-2 dom0_mem=752M,max:752M console=vga --- xenserver/boot/vmlinuz console=tty0 answerfile=http://pxe.sytes.net/answerfiles/xena.cfg --- xenserver/install.img
LABEL XEN server safe
	KERNEL mboot.c32
	APPEND xenserver/boot/xen.gz dom0_max_vcpus=1-2 dom0_mem=max:752M nosmp noreboot noirqbalance acpi=off noapic com1=115200,8n1 console=com1,vga vga=keep --- xenserver/boot/vmlinuz nousb xencons=hvc console=hvc0 console=tty0 answerfile=http://pxe.sytes.net/answerfiles/xena.cfg  --- xenserver/install.img
LABEL Install XEN server multipath
	KERNEL mboot.c32
	APPEND xenserver/boot/xen.gz dom0_max_vcpus=1-2 dom0_mem=max:752M com1=115200,8n1 console=com1,vga --- xenserver/boot/vmlinuz xencons=hvc console=hvc0 console=tty0 answerfile=http://pxe.sytes.net/answerfiles/xena.cfg  device_mapper_multipath=enabled --- xenserver/install.img
LABEL XEN server shell
	KERNEL mboot.c32
	APPEND xenserver/boot/xen.gz dom0_max_vcpus=1-2 dom0_mem=max:752M com1=115200,8n1 console=com1,vga --- xenserver/boot/vmlinuz xencons=hvc console=hvc0 console=tty0 answerfile=http://pxe.sytes.net/answerfiles/xena.cfg  bash-shell --- xenserver/install.img
 

EOF


